<template>
  <div class="shipper-wrap">
    <nr-select v-model="customerId"
               :options="customerSelect"
               :popper-append-to-body="false"
               :props="{ label: 'name', value: 'customerId' }"
               placeholder="请选择发货方"
               @change="input" />
  </div>
</template>

<script>
import nrSelect from "@/components/nr/select/Index";
import { searchCustomer } from "@/api/customer/customer";

export default {
  name: "Shipper",
  components: { nrSelect },
  props: {
    value: {
      type: [String, Number],
      default: null
    }
  },
  data () {
    return {
      customerSelect: [],
      customerId: this.value
    };
  },
  created () {
    this.customerInit();
  },
  methods: {
    async customerInit () {
      let params = { page: 1, size: 10000, status: 1, customerTypes: [0, 1] };
      let response = await searchCustomer(params);
      let { records } = response.data;
      this.customerSelect = records;
    },
    input (value) {
      this.$emit("handleInput", value);
    }
  }
};
</script>

<style></style>
